language: node_js
node_js:
  - 10
  - 9
  - 8
  - 6
env:
  - FRESH_DEPS=false
  - FRESH_DEPS=true
matrix:
  exclude:
    - node_js: 9
      env: FRESH_DEPS=true
    - node_js: 8
      env: FRESH_DEPS=true
    - node_js: 6
      env: FRESH_DEPS=true
cache:
  directories:
    - $HOME/.npm
before_install:
  - npm install --global npm@6.1.0
  - npm --version
install: |
  if [[ ${FRESH_DEPS} == "true" ]]; then
    npm install --no-shrinkwrap --prefer-online;
  else
    npm ci;
    checksum=$(md5sum package-lock.json);
    npm install --package-lock-only;
    if ! echo ${checksum} | md5sum --quiet -c -; then
      echo "package-lock.json was modified unexpectedly. Please rebuild it using npm@$(npm -v) and commit the changes.";
      exit 1;
    fi
  fi
after_success: npx codecov --file=./coverage/lcov.info
